import React from 'react'
import { View, StyleSheet, Text, ScrollView, Image } from 'react-native'
import { ScaleS, ScaleT } from 'src/utils/ScreenUtil'
import BaseJobNature from 'src/pageP/base/base-job-nature'
import NextButton from 'src/components/button/NextButton'
/* redux */
import { connect } from 'react-redux'

@connect(({ CMineCenterStore }) => ({
  jobHuntingModels: CMineCenterStore.jobHuntingModels
}))
class UserJobNature extends BaseJobNature {
  constructor (props) {
    super(props)
    const {
      navigation: {
        state: {
          params: { workNature, id }
        }
      }
    } = this.props
    this.state = {
      ...this.state,
      workNature
    }
    const workNatures = this.props.jobHuntingModels.filter(e => e.workNature && e.workNature[0] !== workNature[0] && e.id !== id).map(e => e.workNature[0])
    this.Wroknatures = this.Wroknatures.map(e => ({
      ...e,
      disable: workNatures.includes(e.name)
    }))
  }

  // Wroknatures
  renderBottomBtn () {
    const { workNature } = this.state
    const workNatureValue = workNature && workNature[0]
    return (
      <NextButton
        style={styles.nextButton}
        title="保存"
        enable={!!workNatureValue}
        onPress={this.nextButtonClick}
      />
    )
  }

  /**
   * 下一步
   * @private
   */
  nextButtonClick = () => {
    const { workNature } = this.state
    const workNatureValue = workNature && workNature[0]
    if (!workNatureValue) {
      return
    }
    const {
      navigation: {
        state: {
          params: { callback }
        }
      }
    } = this.props
    callback && callback(workNature)
    this.goBack()
  }
}
export default UserJobNature

const styles = StyleSheet.create({
  jobNatureIndexView: {
    flexDirection: 'row',
    alignItems: 'flex-end'
  },
  jobNatureIndex: {
    color: '#999999',
    fontSize: ScaleT(20),
    fontWeight: '500'
  },
  jobNatureTotal: {
    color: '#999999',
    fontSize: ScaleT(16),
    fontWeight: '500'
  },
  nextButton: {
    position: 'absolute',
    bottom: ScaleS(20),
    left: ScaleS(32)
  }
})
